package ce.com.cenewbluesdk.uitl;

/**
 * Created by Administrator on 2016/3/7 0007.
 */
public class Util {

    public static int[] getIntArray(byte b) {

        int[] array = new int[8];
        for (int i = 0; i <= 7; i++) {
            array[i] = (b & 1);
            b = (byte) (b >> 1);
        }
        return array;
    }

    public static byte Convert(int[] a) {
        byte b = 0;
        if (a[0] == 1)
            b |= 0x01;    //"|=" 这个符号不知道是做事什么
        if (a[1] == 1)
            b |= 0x02;
        if (a[2] == 1)
            b |= 0x04;
        if (a[3] == 1)
            b |= 0x08;
        if (a[4] == 1)
            b |= 0x10;
        if (a[5] == 1)
            b |= 0x20;
        if (a[6] == 1)
            b |= 0x40;
        if (a[7] == 1) {
            b |= 0x80;
        }
        return b;
    }

    public static byte Convert(boolean[] vector) {
        byte b = 0;
        if (vector[0])
            b |= 0x01;
        if (vector[1])
            b |= 0x02;
        if (vector[2])
            b |= 0x04;
        if (vector[3])
            b |= 0x08;
        if (vector[4])
            b |= 0x10;
        if (vector[5])
            b |= 0x20;
        if (vector[6])
            b |= 0x40;
        if (vector[7]) {
            b |= 0x80;
        }
        return b;
    }

}
